<%--
    Document   : heroesContent
    Created on : Nov 23, 2012, 2:14:54 PM
    Author     : newohybat
--%>

<%@ page contentType="text/html; charset=utf-8" pageEncoding="utf-8" %>
<%@ taglib prefix="s" uri="http://stripes.sourceforge.net/stripes.tld" %>
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
<%@ taglib prefix="f" uri="http://java.sun.com/jsp/jstl/fmt" %>
<%@ taglib uri="http://tiles.apache.org/tags-tiles" prefix="tiles" %>

<s:useActionBean beanclass="cz.muni.fi.pa165.ddtroops.web.actionbeans.HeroActionBean" var="actionBean"/>
<div class="txt">
    <h2><s:label for="hero.list"/></h2>
</div>
<c:if test="${not empty pageContext.request.getParameter('error')}">
    <div class="error">
        <b><s:label for="error.${pageContext.request.getParameter('error')}"/></b>
    </div>
</c:if>
<c:if test="${!pageContext.request.isUserInRole('ROLE_SUPERVISOR')}">
    <div class="raceForm">
        <tiles:insertDefinition name="dd-troops-web.heroes-createForm" />
    </div>
</c:if>
<ul class="raceList">
<c:forEach items="${actionBean.heroes}" var="hero">
    <li class="raceThumbnail">
        <p class="raceName"><s:label for="hero.name"/>:<c:out value="${hero.name}"/></p>
        <p>
            <s:label for="hero.biography"/>:
            <c:choose>
                <c:when test="${hero.biography.length() < 75}">
                    <c:out value="${hero.biography}"/>
                </c:when>
                <c:otherwise>
                    <c:out value="${hero.biography.substring(0,73)}"/>...
                </c:otherwise>
            </c:choose>
        </p>
        <p>
           <s:label for="hero.gender"/>: <c:out value="${hero.gender}"/>
        </p>
        <p>
            <s:label for="hero.race"/>:
                <c:out value="${hero.race.name}"/><br />
        </p>
        <p>
            <s:label for="hero.xp"/>:<c:out value="${hero.xp}"/>
        </p>
        <p>
            <s:label for="hero.profession"/>:
            <c:out value="${hero.profession}"/>
        </p>
        <div class="raceBonuses">
            <c:forEach items="${actionBean.getSkillsOfProffessionAndXP(hero.profession, hero.xp)}" var="sk">
                Skill:&nbsp;<c:out value="${sk.name}"/><br/>
                Description:&nbsp;<c:out value="${sk.description}"/><br/>
                <br/>
            </c:forEach>
        </div>
        <div class="raceBonuses">
            <s:label for="hero.charisma"/>:&nbsp;<c:out value="${hero.charisma}"/>
            <c:if test="${hero.race.charisma > -1}">+</c:if><c:out value="${hero.race.charisma}"/><br/>
            <s:label for="hero.constitution"/>:&nbsp;<c:out value="${hero.constitution}"/>
            <c:if test="${hero.race.constitution > -1}">+</c:if><c:out value="${hero.race.constitution}"/><br/>
            <s:label for="hero.dexterity"/>:&nbsp;<c:out value="${hero.dexterity}"/>
            <c:if test="${hero.race.dexterity > -1}">+</c:if><c:out value="${hero.race.dexterity}"/><br/>
            <s:label for="hero.intelligence"/>:&nbsp;<c:out value="${hero.intelligence}"/>
            <c:if test="${hero.race.intelligence > -1}">+</c:if><c:out value="${hero.race.intelligence}"/><br/>
            <s:label for="hero.strength"/>:&nbsp;<c:out value="${hero.strength}"/>
            <c:if test="${hero.race.strength > -1}">+</c:if><c:out value="${hero.race.strength}"/><br/>
            <s:label for="hero.wisdom"/>:&nbsp;<c:out value="${hero.wisdom}"/>
            <c:if test="${hero.race.wisdom > -1}">+</c:if><c:out value="${hero.race.wisdom}"/><br/>
        </div>
        <div class="raceLinks">
            <s:link beanclass="cz.muni.fi.pa165.ddtroops.web.actionbeans.HeroActionBean" event="delete"  class="delete">
                <s:param name="hero.getId()" value="${hero.id}"/>
                <img src="<%=request.getContextPath()%>/images/deleteIcon.gif"/>
            </s:link>
            <br/>
            <s:link beanclass="cz.muni.fi.pa165.ddtroops.web.actionbeans.HeroActionBean" event="edit">
                <s:param name="hero.getId()" value="${hero.id}"/>
                <img src="<%=request.getContextPath()%>/images/editIcon.png"/>
            </s:link>
        </div>
    </li>
</c:forEach>
</ul>
